package com.zhuss.aop;

import java.lang.reflect.Method;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAspect {
	
	@Pointcut("execution(public * com.zhuss.common.Processor.process(java.lang.Object))")
	public void pointCut() {
		
	}
	
	@AfterReturning("pointCut()")
	public void around(JoinPoint point) throws Throwable {
		String targetName = point.getTarget().getClass().getName();
        // String methodName = point.getSignature().getName();
        Object[] arguments = point.getArgs();
        Class<?> targetClass = Class.forName(targetName);
        Method method = targetClass.getMethod("log", Object.class);
        method.invoke(point.getTarget(), arguments[0]);
       /* Object object = point.proceed();
        return object;*/
	}
	
}
